package jing.upnp.ssdp.type;

import android.util.Log;

import jing.upnp.ssdp.type.usn.Usn;

/**
 * Created by ouyang on 15-9-10.
 */
public class UpnpEntity {

    private static final String TAG = "UpnpEntity";
    private String ip;
    private int maxAge;
    private String location;
    private String nt;
    private String st;
    private String date;
    private String server;
    private Usn usn;
    private String ext;
    private String al;
    private long lastOnlineTime;

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getMaxAge() {
        return maxAge;
    }

    public void setMaxAge(int maxAge) {
        this.maxAge = maxAge;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getSt() {
        return st;
    }

    public void setSt(String st) {
        this.st = st;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getServer() {
        return server;
    }

    public void setServer(String server) {
        this.server = server;
    }

    public Usn getUsn() {
        return usn;
    }

    public void setUsn(Usn usn) {
        this.usn = usn;
    }

    public String getExt() {
        return ext;
    }

    public void setExt(String ext) {
        this.ext = ext;
    }

    public String getNt() {
        return nt;
    }

    public void setNt(String nt) {
        this.nt = nt;
    }

    public String getAl() {
        return al;
    }

    public void setAl(String al) {
        this.al = al;
    }

    public long getLastOnlineTime() {
        return lastOnlineTime;
    }

    public void setLastOnlineTime(long lastOnlineTime) {
        this.lastOnlineTime = lastOnlineTime;
    }

    public long getNextOnlineTime() {
        return this.lastOnlineTime + maxAge;
    }

    public long getOnlineTimeout() {
        long timeout = (getNextOnlineTime() - System.currentTimeMillis() / 1000);
        if (timeout < 0) {
            Log.d(TAG, "getOnlineTimeout: timeout < 0");
            timeout = maxAge;
        }

        return timeout;
    }
}